package com.ruoyi.dm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.dm.domain.po.FallRecordPO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface FallRecordMapper extends BaseMapper<FallRecordPO> {

    @Delete(" DELETE FROM COLLECT_FALL_RECORD WHERE id IN (" +
            " SELECT id FROM COLLECT_FALL_RECORD r,(" +
            " SELECT SATELLITE,EPOCH_TIME FROM  (" +
            " SELECT count(1) num,EPOCH_TIME,SATELLITE FROM COLLECT_FALL_RECORD GROUP BY SATELLITE,EPOCH_TIME  ) WHERE num>1 ) dd WHERE r.SATELLITE  = dd.SATELLITE AND r.EPOCH_TIME = dd.EPOCH_TIME " +
            " EXCEPT " +
            " SELECT max(id) FROM COLLECT_FALL_RECORD r,(" +
            " SELECT SATELLITE,EPOCH_TIME FROM  (" +
            " SELECT count(1) num,SATELLITE,EPOCH_TIME FROM COLLECT_FALL_RECORD GROUP BY SATELLITE,EPOCH_TIME  ) WHERE num>1 ) dd WHERE r.SATELLITE  = dd.SATELLITE AND r.EPOCH_TIME = dd.EPOCH_TIME GROUP BY r.SATELLITE,r.EPOCH_TIME " +
            ")")
    void deleteRepeat();
}
